(function () {

	function Repository(dataSource) {
		this.processRequest = function(request) {
			if (!request.method) throw "Nie określono metody w zapytaniu";
			switch (request.method) {
				case "szukaj":
					return dataSource.find(request.model, request.operators);
				case "dodaj":
					return dataSource.add(request.model);
				case "edytuj":
					return dataSource.update(request.model);
				case "usun":
					return dataSource.remove(request.model);
				default:
					throw "Nieobsługiwana metoda: " + request.method;
			}
		};
	};

	module.exports = Repository;

})();